<template>
  <div>
      <!-- 头部滚动区域 -->
    <div id="slider" class="mui-slider">
      <div
        id="sliderSegmentedControl"
        class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted"
      >
        <div class="mui-scroll" >
          <a :class="['mui-control-item',item.id===0 ?'mui-active':'']" v-for="item in arr" :key="item.id" @click="getimg(item.id)">{{item.title}}</a>                                           
         
        </div>
      </div>
    </div>

    <!-- 懒加载区域 -->
<ul>
  <router-link v-for="item in list" :key="item.id" :to="'/home/Photoinfo/'+item.id" tag="li">
    <img v-lazy="item.img_url">
    <div class="info">
        <div class="info-title">{{item.title}}</div>
        <div class="info-zhaiyao">{{item.zhaiyao}}</div>
    </div>
  </router-link>
</ul>



  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
      list:[]
    };
  },
  methods: {
    getdadalist() {
      this.$axios("/api/getimgcategory").then(res => {
        res.data.message.unshift({ title: "全部", id: 0 });
        this.arr = res.data.message;
        // console.log(this.arr);
      });
    },
    getimg(cateid){
        this.$axios('/api/getimages/' + cateid).then(res=>{
            this.list=res.data.message
            console.log( this.list)
        })
    }
  },
  created() {
    this.getdadalist();
    this.getimg(0)
  },
  mounted() {
    mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
  }
};
</script>

<style scoped lang="scss">
* {
  touch-action: none;
}
.info{
      background-color: pink;
      text-align:left; 
      .info-title{
          font-size: 18px;
          font-weight: 800;
          margin-bottom: 10px;
      }
      .info-zhaiyao{
          font-size: 14px;
      }
  }
</style>
